#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main(){
    double dp[102][102];
    int x1,y1,x2,y2,n;
    dp[0][0]=0;
    for(int i=0;i<101;i++){
        int x=0,y=i;
        while (y>=0)
        {   
            if(x==0){
                dp[0][i]=dp[i-1][0]+sqrt(i*i+(i-1)*(i-1));
            }else{
                dp[x][y]=dp[x-1][y+1]+sqrt(2.0);
            }
            x++,y--;
        }
    }
    while (cin>>n)
    {
        for(int i=0;i<n;i++){
            cin>>x1>>y1>>x2>>y2;
            cout<<fixed<<setprecision(3)<<abs(dp[x2][y2]-dp[x1][y1])<<endl;
        }
    }
    
   
}